<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c"  uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html >
  <head>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<title>凯胜项目管理系统</title>
	<style type="text/css">
		body{
			padding-top:50px;
		}
	</style>

  </head>
  
  <body class ="body"> 
    <%@include file="same2.jsp" %>
	<div class="container">
		<div class="row">
			<%@include file="same.jsp" %>
			<div class="span9">
			<div style="float:right;margin-top:15px"><a class="btn btn-primary" href="file.jspx?method=newFile&id=${param.id }"><i class="icon-share icon-white"></i>上传资料</a></div>
				<div class="clear"></div>
				 <ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:55px">
				 
					<li class="active">
					
						<a href="task.html"><i class="icon-th"></i>文件共享>${singleFilesId.filesname }</a>
					</li>
					<li style="float:right"><a href="#" class="link-black"><i class="icon-trash "></i></a></li>
				</ul>
				
				<div class="wall" style="border-top:none; border:1px solid #dddddd ">
					<div style="margin-top:20px;margin-left:10px;margin-right:10px " >
						<table class="table table-striped">
						<thead>
							<tr>
								<th width="30px"></th>
								<th width="60%">名称</th>
								<th width="20%">大小</th>
								<th>创建人</th>
								<th></th>
							</tr>
						</thead>
						<tbody>
							<c:choose>
								<c:when test = "${empty requestScope.fileList.list }">
									<tr>
											<td colspan = "4">暂时还没有相关的文件！</td>
									</tr>
								</c:when>
								<c:otherwise>
								
									<c:forEach items = "${requestScope.fileList.list}" var = "file">
										<tr>
											<c:choose>
												<c:when test="${file.type == '.doc' }">
													<td><img id = "myimg" src="img/page_word.png"/></td>
												</c:when>
												<c:when test="${file.type == '.xls' }">
													<td><img id = "myimg" src="img/xls.png"/></td>
												</c:when>
												<c:when test="${file.type == '.xls' }">
													<td><img id = "myimg" src="img/file_pdf.png"/></td>
												</c:when>
												<c:otherwise>
													<td><img id = "myimg" src="img/2.png"/></td>
												</c:otherwise>
											
											</c:choose>
											
											<td id = "mytd"><a id = "myfilename" href="file.jspx?method=toDownload&name=${file.fileName}" class="link-black">${file.name }</a></td>
											<td> ${file.filesize }</td>
											<td>${file.user.username }</td>
											<c:choose>
												<c:when test="${sessionScope.user.username == file.user.username}">
													<td><a class = "mydel" href="#" class="link-black"><i class="icon-trash"></i></a></td>
													<div class = "modal hide "  id="mymodal" >
													<div class = "modal-header">
															<input type="button" value="x" style = 'color:black' class = "close" data-dismiss = "modal"/>
															<h3>删除文件</h3>
													</div>
														<div class = "modal-body" style = "text-align:center;height:40px;margin-top:10px">
																<div ><img alt="" src="img/file_success.png">是否删除 ${file.name }?</div>		
														</div>
														<div class = "modal-footer">
															<a href="file.jspx?method=del&id=${file.id}" class = "btn " >是</a>
															<a href="#" class = "btn btn-primary" data-dismiss = "modal">否</a>
														</div>
													</div>
												
												</c:when>
											
											
											</c:choose>
											
										</tr>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</tbody>
						</table>
						<div><a href="file.jspx?">←返回</a></div>
					</div>
				</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src = "js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#myid li").eq(5).addClass("active");
			$("#myid i").eq(3).addClass("  icon-white");
			$(".mydel").click(function(){
				$("#mymodal").modal("show");
			
			
			});
			/* $("#mytd").each(function(){
				var v =$(this).html();
				var str = v.substr(v.lastIndexOf("."));
				if(str == ".doc"){
					
				}
			
			}); */
		});
		
	</script>
  </body>
</html>
